/**
 * Created by haocongshun on 2016/8/4.
 */
$(function () {
    $("#projectTop").show();
    $("#projectTable").show();
    $("#setTop").hide();
    $("#setFrom").hide();
    getAll();
    $("#back").click(function () {
        location.href="/TaskCollection/teacher/project.jsp";
    });
});
//获取当前项目所有的进度报告
function getAll() {
    var url = "/TaskCollection/Projectprogress/teacherGetAll.wst";
    var dataAll = {};
    dataAll.id=location.search.split("=")[1];
    var resultuse = "";
    $.ajaxSetup({
        async : false
    });
    $.post(url,dataAll,function (result) {
        $("#projectTop span").text(result.project.project_name+"项目的进度列表");
        for(var i  = 0;i < result.getAll.length;i++){
            var newrow = "<tr>" +
                "<td class='date' data-i='"+i+"'>"+result.getAll[i].projectProgress_date+"</td>" +
                "<td>"+result.getAll[i].projectProgress_name+"</td>" +
                "<td>"+result.project.projectTeam.projectTeamLeader.student_name+"</td>" +
                "<td ><a href='/TaskCollection/Projectprogress/download.wst?id="+result.getAll[i].projectProgress_id+"'>"+result.getAll[i].projectProgress_file+"</a></td>" +
                "<td><input class='btn see' type='button' value='查看'></td> " +
                "</tr>";
            $("#progress tr:last").after(newrow);
        }
        resultuse=result;
    },"json");
    bindsee(resultuse);
}
function bindsee(resultlast) {
    $(".see").click(function () {
        $("#projectTop").hide();
        $("#projectTable").hide();
        $("#setTop").show();
        $("#setFrom").show();
        var i = $(this).parent().parent().children(".date").attr("data-i");
        $("#name span").text(resultlast.getAll[i].projectProgress_name);
        $("#time span").text(resultlast.getAll[i].projectProgress_date);
        $("#student span").text(resultlast.project.projectTeam.projectTeamLeader.student_name);
        $("#content textarea").text(resultlast.getAll[i].projectProgress_content);
        $("#see-back").click(function () {
            $("#projectTop").show();
            $("#projectTable").show();
            $("#setTop").hide();
            $("#setFrom").hide();
            $("#progress tr:not(:first)").html("");
            getAll();
        });
    });
}